package hutech.ksv.entity;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

public class QuanAnDataModel extends ListDataModel<ThongTinQuanAnEntity> implements
		SelectableDataModel<ThongTinQuanAnEntity> {

	public QuanAnDataModel() {
		
	}
	
	public QuanAnDataModel(List<ThongTinQuanAnEntity> data) {
		super(data);
	}

	@Override
	public ThongTinQuanAnEntity getRowData(String rowKey) {
		List<ThongTinQuanAnEntity> danhSachQuanAn = (List<ThongTinQuanAnEntity>) getWrappedData();
		
		for(ThongTinQuanAnEntity c : danhSachQuanAn) {
			if(c.getMaQA() == Integer.parseInt(rowKey)) {
				return c;
			}
		}
		return null;
	}

	@Override
	public Object getRowKey(ThongTinQuanAnEntity thongTinQuanAnEntity) {
		return thongTinQuanAnEntity.getMaQA();
	}
	
}
